@{
    Ajax.Dna().Widget()
        .UserPreferences(@<text>
    @{ Ajax.Dna().TreeView(item.GenerateFieldID("TreeView"))
            .HtmlAttributes(new { style = "height:200px;border:1px solid #cccccc;overflow:auto;" })
            .Options(opts =>
            {
                opts.OnNodeSelected = "$(\"#" + item.GenerateFieldID("ParentID") + "\").val($(node).attr(\"key\"));";
                opts.SinglePathExpand = true;
            })
             .Bind(WebSiteContext.Current.SiteMapNodeProvider.RootNode, (node) =>
                            {
                                if (node.Key.Equals("0"))
                                    node.ImageUrl = Url.Content("~/content/images/icon_earth_16.gif");
                                else
                                    node.ImageUrl = Url.Content("~/content/images/icon_aspx_16.png");

                                bool showInMenu = node.Attributes.ContainsKey("ShowInMenu") ? bool.Parse(node.Attributes["ShowInMenu"].ToString().ToLower()) : true;
                                var page = node.Item as DNA.Mvc.WebPage;
                                if (!showInMenu)
                                {
                                    node.Attributes.Add("style", "color: #cccccc;");
                                    node.ImageUrl = Url.Content("~/content/images/icon_hide_aspx_16.png");
                                }
                                else
                                {
                                    if (node.Attributes.ContainsKey("style"))
                                        node.Attributes["style"] = "color:#000000;";
                                    else
                                        node.Attributes.Add("style", "color:#000000;");
                                }

                                if ((page != null) && (!page.AllowAnonymous))
                                    node.ImageUrl = Url.Content("~/content/images/icon_security_aspx_16.png");

                                node.NavigateUrl = "";
                                return true;
                            })
                            .DragAndDrop(true)
                            .Render();
    }
    <input type="hidden" value="@item.GetInt("ParentID")" id="@item.GenerateFieldID("ParentID")" name="@item.GenerateFieldID("ParentID")" />
    </text>)
        .Content(@<text>
    @{ var pages = WebSiteContext.Current.DataContext.WebPages.GetChildren(WebSiteContext.Current.Web.Id, item.GetInt("ParentID")); }
    <table style="width: 100%;">
        @foreach (var page in pages)
        {
            <tr>
                <td style="width: 64px;">
                    @if (!string.IsNullOrEmpty(page.ImageUrl))
                    {
                        <img src="@Url.Content(page.ImageUrl)" alt="@page.Title" />
                    }
                </td>
                <td style="vertical-align: top;">
                    <h3 class="d-page-title" style="margin-top: 0px;"><a href="@Url.Content(page.Path)" title="@page.Title">@page.Title</a>
                    </h3>
                    <div class="d-page-desc">@page.Description</div>
                </td>
            </tr>
        }
    </table>
    </text>)
        .Render();
}
